﻿using System.Collections.Generic;
using System.Linq;

namespace nRoute.Components.Composition.Adapters
{
    public class CollectionLocatorAdapter<T> 
        : LocatorAdapterBase<T, ICollection<T>>
        where 
            T : class
    {
        public CollectionLocatorAdapter()
            : base((b, s) =>
            {
                // note_ we are ignoring the string "s" type sent in
                if (b.ResourceCatalog.IsResourceable<T>())
                {
                    return b.ResourceCatalog.GetAllResources<T>().ToList();
                }
                else
                {
                    return Enumerable.Empty<T>().ToList();
                }
            }) { }
    }
}